package cn.topevery.garden.wapi.controller;

import cn.topevery.garden.dal.logic.OneMapLogic;
import hw.topevery.framework.dto.PointDto;
import hw.topevery.framework.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api("一张图数据获取接口")
@RestController
@RequestMapping("/oneMap")
public class OneMapController extends BaseController {
    @Autowired
    private OneMapLogic onemapLogic;

    @ApiOperation("园林概览")
    @GetMapping("/gardenOverview")
    public JsonResult<Map<String, Object>> gardenOverview() {
        Map<String, Object> resultMap = onemapLogic.gardenOverview();
        return JsonResult.ok(resultMap);
    }

    @ApiOperation("基础设施数量")
    @GetMapping("/facilitiesCount")
    public JsonResult<List<Map<String, Object>>> facilitiesCount() {
        List<Map<String, Object>> result = onemapLogic.facilitiesCount();
        return JsonResult.ok(result);
    }

    @ApiOperation("工单处置统计--按日统计(近一周数据countType=1)/ 按月统计(近一年数据countType=2) /按年统计(近三年数据countType=3)")
    @GetMapping("/eventCount")
    public JsonResult<?> eventCount(@RequestParam Integer countType) {
        List<Map<String, Object>> result = onemapLogic.eventCount(countType);
        return JsonResult.ok(result);
    }

    @ApiOperation("养护任务统计")
    @GetMapping("/planCount")
    public JsonResult<?> planCount() {
        List<Map<String, Object>> result = onemapLogic.planCount();
        return JsonResult.ok(result);
    }

    @ApiOperation("公园选址分析（无用）")
    @PostMapping("/parkPositionSelect")
    public JsonResult<?> parkPositionSelect(@RequestBody Map<String, List<List<PointDto>>> param) {
        return onemapLogic.parkPositionSelect(param);
    }
}
